{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/containers/Dialogs.tsx\",\n  _s = $RefreshSig$();\nimport React from \"react\";\nimport { Dialogs as DialogList } from \"../components/\";\nimport { getOtherUserForNotMultiChat } from \"../utils/Membership\";\nimport { observer } from \"mobx-react-lite\";\nimport { Context } from \"../index\";\nimport { getUserName } from \"../utils/User\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst Dialogs = () => {\n  _s();\n  const {\n    store\n  } = React.useContext(Context);\n  const [chatsList, setChatsList] = React.useState();\n  const [inputValue, setInputValue] = React.useState('');\n  const [sort, setSort] = React.useState();\n  const [flag, setFlag] = React.useState(false);\n  React.useEffect(() => {\n    if (store.getChats().items === undefined) {\n      store.getChatsFromAPI().then();\n    } else {\n      setFlag(true);\n    }\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n  React.useEffect(() => {\n    setChatsList({\n      ...store.getChats()\n    });\n    setSort(chatsList);\n    console.log(chatsList, sort);\n\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [store.chats, flag]);\n  const onChangeInput = function () {\n    let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n    if (chatsList && chatsList.items.length > 0) {\n      setSort({\n        items: chatsList.items.filter(dialog => dialog.multiChat ? dialog.name.toLowerCase().indexOf(value.toLowerCase()) >= 0 : getUserName(dialog.membership ? getOtherUserForNotMultiChat(store, dialog.membership) : store.getProfile()).toLowerCase().indexOf(value.toLowerCase()) >= 0)\n      });\n    }\n    setInputValue(value);\n  };\n  return /*#__PURE__*/_jsxDEV(DialogList, {\n    chatsList: sort || {\n      items: []\n    },\n    onSearch: onChangeInput,\n    inputValue: inputValue\n  }, void 0, false, {\n    fileName: _jsxFileName,\n    lineNumber: 56,\n    columnNumber: 12\n  }, this);\n};\n_s(Dialogs, \"d82PKw7Fdxck3JJCgwoPeKL1FVU=\");\n_c = Dialogs;\nexport default _c2 = observer(Dialogs);\nvar _c, _c2;\n$RefreshReg$(_c, \"Dialogs\");\n$RefreshReg$(_c2, \"%default%\");","map":{"version":3,"names":["React","Dialogs","DialogList","getOtherUserForNotMultiChat","observer","Context","getUserName","store","useContext","chatsList","setChatsList","useState","inputValue","setInputValue","sort","setSort","flag","setFlag","useEffect","getChats","items","undefined","getChatsFromAPI","then","console","log","chats","onChangeInput","value","length","filter","dialog","multiChat","name","toLowerCase","indexOf","membership","getProfile"],"sources":["/data/messenger.client/src/containers/Dialogs.tsx"],"sourcesContent":["import React from \"react\";\nimport {Dialogs as DialogList} from \"../components/\";\nimport {ChatsListResponse} from \"../models/response/ChatsListResponse\";\nimport {getOtherUserForNotMultiChat} from \"../utils/Membership\";\nimport {observer} from \"mobx-react-lite\";\nimport {Context} from \"../index\";\nimport {getUserName} from \"../utils/User\";\nimport {ChatsListItem} from \"../models/response/ChatsListItem\";\n\nconst Dialogs:React.FC = () => {\n    const {store} = React.useContext(Context);\n    const [chatsList, setChatsList] = React.useState<ChatsListResponse>();\n    const [inputValue, setInputValue] = React.useState<string>('');\n    const [sort, setSort] = React.useState<ChatsListResponse>();\n    const [flag, setFlag] = React.useState<boolean>(false);\n\n    React.useEffect(() => {\n        if (store.getChats().items === undefined) {\n            store.getChatsFromAPI().then();\n        } else {\n            setFlag(true);\n        }\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, []);\n\n    React.useEffect(() => {\n        setChatsList({\n            ...store.getChats()\n        });\n        setSort(chatsList);\n\n        console.log(chatsList, sort)\n\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, [store.chats, flag]);\n\n    const onChangeInput = (value: string = '') => {\n        if (chatsList && chatsList.items.length > 0) {\n            setSort({\n                items: chatsList.items.filter(\n                    (dialog: ChatsListItem) => (\n                        (dialog.multiChat)? dialog.name.toLowerCase().indexOf(value.toLowerCase()) >= 0:\n                            getUserName(\n                                dialog.membership?\n                                    getOtherUserForNotMultiChat(store, dialog.membership):\n                                    store.getProfile()\n                            ).toLowerCase().indexOf(value.toLowerCase()) >= 0\n                    )\n                )\n            });\n        }\n\n        setInputValue(value);\n    };\n\n    return <DialogList\n        chatsList={sort || {items: []}}\n        onSearch={onChangeInput}\n        inputValue={inputValue}\n    />;\n\n};\n\nexport default observer(Dialogs);"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,OAAO,IAAIC,UAAU,QAAO,gBAAgB;AAEpD,SAAQC,2BAA2B,QAAO,qBAAqB;AAC/D,SAAQC,QAAQ,QAAO,iBAAiB;AACxC,SAAQC,OAAO,QAAO,UAAU;AAChC,SAAQC,WAAW,QAAO,eAAe;AAAC;AAG1C,MAAML,OAAgB,GAAG,MAAM;EAAA;EAC3B,MAAM;IAACM;EAAK,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACH,OAAO,CAAC;EACzC,MAAM,CAACI,SAAS,EAAEC,YAAY,CAAC,GAAGV,KAAK,CAACW,QAAQ,EAAqB;EACrE,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGb,KAAK,CAACW,QAAQ,CAAS,EAAE,CAAC;EAC9D,MAAM,CAACG,IAAI,EAAEC,OAAO,CAAC,GAAGf,KAAK,CAACW,QAAQ,EAAqB;EAC3D,MAAM,CAACK,IAAI,EAAEC,OAAO,CAAC,GAAGjB,KAAK,CAACW,QAAQ,CAAU,KAAK,CAAC;EAEtDX,KAAK,CAACkB,SAAS,CAAC,MAAM;IAClB,IAAIX,KAAK,CAACY,QAAQ,EAAE,CAACC,KAAK,KAAKC,SAAS,EAAE;MACtCd,KAAK,CAACe,eAAe,EAAE,CAACC,IAAI,EAAE;IAClC,CAAC,MAAM;MACHN,OAAO,CAAC,IAAI,CAAC;IACjB;IACA;EACJ,CAAC,EAAE,EAAE,CAAC;EAENjB,KAAK,CAACkB,SAAS,CAAC,MAAM;IAClBR,YAAY,CAAC;MACT,GAAGH,KAAK,CAACY,QAAQ;IACrB,CAAC,CAAC;IACFJ,OAAO,CAACN,SAAS,CAAC;IAElBe,OAAO,C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